<template>
  <div>
    <form action="">
      <label for="">input:</label>
      <input type="text" v-model="values" />
      <button type="button" @click="paduan">提交</button>
    </form>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const values = ref()
let zhengze = /\d+/

const paduan = () => {
  if (zhengze.test(values.value)) {
    values.value = ''
    return alert('验证成功！')
  } else {
    values.value = ''
    return alert('验证失败！')
  }
}
</script>

<style></style>
